Weird php syntax! It is found that a php statement used to determine whether a string is a steamed stuffed bun string is quite strange.
See the following statement:
Echo "A1:". (strpos ("csd", "c "))."";Echo "A2:". (strpos ("csd", "c")> = 0 )."";Echo "B1:". (strpos ("csd", "h", 0 ))."";Echo "B2:". (strpos ("csd", "h", 0)> = 0 )."";
If (strpos ("abc", "a")> = 0){Echo "a in abc "."";}Else{Echo "a not in abc "."";}
If (strpos ("abc", "u")> = 0){Echo "u in abc "."";}Else{Echo "u not in abc
Find a sentence that PHP uses to determine whether a string is a bunch of buns rather weird.
Look at the following statement:
echo "A1:". (Strpos ("CSD", "C")). "";echo "A2:". (Strpos ("CSD", "C") >=0). "";echo "B1:". (Strpos ("CSD", "H", 0)). "";echo "B2:". (Strpos ("CSD", "H", 0) >=0). "";
if (Strpos ("abc", "a") >=0){echo "A in ABC". "";}Else{echo "A not in ABC". "";}
if (Strpos ("abc", "U") >=0){echo "u in abc". "";}Else{echo "U not in abc". "";}
if (Strpos ("A", "abc") >=0){echo "AB
". "";}
The expected value is that the source string "U" is smaller than the substring "ABC", and the source string "U" does not contain the substring "ABC", where the result is opposite to the expected value
if (strpos ("U", "abc") >=0){echo "ABC in U". ""; ABC in U}Else{echo "ABC not in U". "";}
The results displayed
a1:0a2:1B1:b2:1A in ABCu in ABCABC in aABC in U
Definition and usage
The Strpos () function returns the position of the first occ
The next sequence, which represents the maximum matching length of the substring's prefix. For example, String c[], Next[i] represents the maximum matching length of the prefix to the suffix in substring c[0. i].For example, if the substring is abcuab, its prefix is a, AB, ABC, ABCU, Abcua, suffix is b, AB, UAB, CUAB, BCUAB, where the matching maximum substring is AB, the length is 2.Calculate Next's value by definition Public Static int[] Getnext
change(1) Insert data: from app.models import User from app import db # Create a new user u = User () u.username = " abc ' (2) Find data: #returns all users saved to listUser_list =User.query.all ()#find the first user username for ABC, return the user instanceU = User.query.filter_by (username='ABC'). First ()#Blur Find all users with a user name ending in CUser_list = User.query.filter (Username.endswith ('C') . All ()#find a user with a user name other than
smaller than the substring "ABC", and the source string "U" does not contain the substring "ABC", where the result is opposite to the expected valueif (strpos ("U", "abc") >=0){echo "ABC in U". " ABC in U}Else{echo "ABC not in U". " }The results displayeda1:0a2:1B1:b2:1A in ABCu in ABCABC in aABC in UDefinition and usageThe Strpos () function returns the position of the first occurrence of a string in another string.If the string is not found, false
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.